<?php use_helper('Number') ?>
<?php use_helper('Javascript') ?>
<?php /* @var $product Product */ ?>

<?php if (isset($categoryLast)): ?>
    <div class="title">
        <?php echo $categoryLast ?>
    </div>
    <?php else: ?>
    <div class="title">
        <?php if($sf_context->getInstance()->getActionName() == 'new'): ?>
            <?php echo __('new products') ?>
        <?php else: ?>
            <?php echo __('sales') ?>
        <?php endif; ?>
    </div>
<?php endif; ?>

<!--
<div class="path">
    <a href="#"><?php echo __('new products') ?></a>
</div>
-->

<table cellpadding="0" cellspacing="0" class="goods">
<tr>
<td>

<?php foreach ($products as $product): ?>

    <?php include_partial('product/product', array('product' => $product)); ?>
<?php endforeach; ?>

</td>
</tr>
</table>

<?php if (isset($pager) and $pager->haveToPaginate()): ?>

<hr style="width: auto; margin: 10px 20px;" />

<div class="paging">
  <?php echo link_to(
                image_tag(
                    'resultset_first.png'
                    , array(
                        'border' => '0'
                        , 'alt' => __('first')
                        , 'title' => __('first')
                        , 'style' => 'margin-bottom: -3px;'
                    )
                )
                , 'product/list?p=' . $pager->getFirstPage()
                    . '&id=' . $categoryId
            ) ?>
  <?php echo link_to(
                image_tag(
                    'resultset_previous.png'
                    , array(
                        'border' => '0'
                        , 'alt' => __('previous')
                        , 'title' => __('previous')
                        , 'style' => 'margin-bottom: -3px;'
                    )
                )
                , 'product/list?p='.$pager->getPreviousPage()
                    . '&id=' . $categoryId
            ) ?>
  <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
    <?php echo ($page == $pager->getPage()) ? $page : link_to($page, 'product/list?p='.$page. '&id=' . $categoryId) ?>
    <?php if ($page != $pager->getCurrentMaxLink()): ?>
      <?php echo image_tag(
                        'bullet_darker_blue.png'
                        , array(
                            'border' => '0'
                            , 'alt' => __('bullet')
                            , 'style' => 'margin-bottom: -3px;'
                        )
                    ) ?>
    <?php endif ?>
  <?php endforeach ?>
    <?php echo link_to(
                image_tag(
                    'resultset_next.png'
                    , array(
                        'border' => '0'
                        , 'alt' => __('next')
                        , 'title' => __('next')
                        , 'style' => 'margin-bottom: -3px;'
                    )
                )
                , 'product/list?p='.$pager->getNextPage()
                    . '&id=' . $categoryId
            ) ?>
    <?php echo link_to(
                image_tag(
                    'resultset_last.png'
                    , array(
                        'border' => '0'
                        , 'alt' => __('last')
                        , 'title' => __('last')
                        , 'style' => 'margin-bottom: -3px;'
                    )
                )
                , 'product/list?p='.$pager->getLastPage()
                    . '&id=' . $categoryId
            ) ?>
</div>

<?php endif ?>
